package com.gushi.JavaLearn;

import com.gushi.JavaLearn.report.rowClass.rcStudent;
import com.gushi.util.*;
import com.gushi.JavaLearn.entity.*;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.UUID;
import org.apache.poi.*;
import org.apache.poi.hssf.record.FontRecord;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;

import com.gushi.util.*;
import com.gushi.util.excel.*;

public class App {




    /**
     * 获取属性名数组
     * */
    public static String[] getFiledName(Object obj) {

        Field[] fields = obj.getClass().getDeclaredFields();
        String[] fieldNames = new String[fields.length];

        for(int i = 0; i < fields.length; i++){

            System.out.println(fields[i].getType());
            fieldNames[i] = fields[i].getName();
        }

        return fieldNames;
    }



    public App () {

        rcStudent stu = new rcStudent(1, "顾世豪", "男", 24, "浙江省杭州市");

        Field field = stu.getClass().getDeclaredFields()[1];


        try {
            field.setAccessible(true);
            Object obj = field.get(stu);
            System.out.println(obj.toString());
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }


        rcStudent[] stuList = new rcStudent[] {
            new rcStudent(1, "顾世豪", "男", 24, "浙江省杭州市"),
            new rcStudent(2, "段廷瑞", "男", 26, "拱墅区"),
            new rcStudent(3, "周亚楠", "女", 25, "杭州市萧山区"),
            new rcStudent(4, "江泽民", "男", 95, "上海市")
        };



        gsExcel.writeExcel(stuList, "./test.xls");











//        System.out.println(dateTime.nowToPathString());
//
//        et_student student = new et_student();
//        student.setName("顾世豪");
//        student.setAddress("浙江省杭州市萧山区");
//        student.setSex(1);
//        student.setAge(24);
//        student.setRemark("一个程序员");
//        student.setId(1);
//        student.setUuid(UUID.randomUUID());
//
//
//        Field[] fields = student.getClass().getDeclaredFields();
//
//        Field fdName = fields[2];
//        Annotation anttn = fdName.getAnnotations()[0];
//
//        testA s = (testA)anttn;
//        String hh =  s.name();
//
//
//        System.out.println(gsJson.toJson(student));


//        HSSFWorkbook workbook = new HSSFWorkbook();
//
//        HSSFCellStyle hssfCellStyle = workbook.createCellStyle();
//        hssfCellStyle.setAlignment(HorizontalAlignment.CENTER);
//        hssfCellStyle.setFillForegroundColor((short) 0x1200);
//        hssfCellStyle.setFillPattern(FillPatternType.THIN_BACKWARD_DIAG);
//        HSSFFont font = workbook.createFont();
//        font.setFontName("宋体");
//        font.setFontHeightInPoints((short)16);//设置字体大小
//        hssfCellStyle.setFont(font);
//
//        Sheet sheet = workbook.createSheet();
//        Row headRow = sheet.createRow(0);
//        for (int x = 0; x < 10; ++x) {
//            sheet.setColumnWidth(x, 4200);
//            Cell cell = headRow.createCell(x);
//            cell.setCellValue("列：" + x);
//            cell.setCellStyle(hssfCellStyle);
//        }
//
//
//
//        try {
//            FileOutputStream fileOutputStream = new FileOutputStream("./test.xls");
//            workbook.write(fileOutputStream);
//            fileOutputStream.close();
//        }
//        catch (IOException e) {
//            System.out.println(e.getMessage());
//        }
    }
}
